package com.hirstlogics.boxarrow.model;

public class IdManager {
	private static IdManager idManager;
	public static final int NULL_ID = -1;
	private int maxId = NULL_ID;
	

	private IdManager() {
		IdManager.idManager = this;
	}
	
	public static IdManager getInstance() {
		IdManager temp=null;
		if (idManager == null) temp = new IdManager();
		assert(temp==idManager);
		return idManager;
	}
	
	public int createId() {
		return ++maxId;
	}
	
	public void readThing(HasId thing) {
		if (thing!= null && thing.getId()>maxId)
			maxId = thing.getId();
	}
	
}
